﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Engine.Physics
{
    public interface ICollisionable
    {
        CollisionType Type { get; set; }
        BoundingBox BBox { get; }
        BoundingSphere Sphere { get; }
        Plane Plane { get; }
        
        Matrix World { get; }
        Matrix ParentWorld { get; }

        event EventHandler<CollisionEventArgs> Collision;
        event EventHandler<CollisionEventArgs> Colliding;

        void OnCollision(CollisionEventArgs args);
        void OnColliding(CollisionEventArgs args);

    }

    public class CollisionEventArgs : EventArgs
    {
        public ICollisionable Other { get; private set; }

        /// <summary>
        /// The normal of the collision.
        /// </summary>
        public Vector3 Normal { get; private set; }

        public CollisionEventArgs(ICollisionable other, Vector3 normal)
            : base()
        {
            Other = other;
            Normal = normal;
        }

    }

    public enum CollisionType
    {
        Sphere,
        Box,
        Plane
    }
}
